﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Snake
{
    class Menu
    {
        private Texture2D f_exitButtonTexture;
        private Texture2D f_startButtonTexture;
        private Texture2D f_backgroundTexture;
        private Vector2 f_exitButtonPos;
        private Vector2 f_startButtonPos;
        private Vector2 f_backgroundPos;
        public Menu(Texture2D exitTextur,Texture2D startTextur,Texture2D backgroundTextur)
        {
            f_exitButtonTexture = exitTextur;
            f_startButtonTexture = startTextur;
            f_backgroundTexture = backgroundTextur;
            f_backgroundPos = new Vector2(200, 50);
            f_exitButtonPos = new Vector2(250, 200);
            f_startButtonPos = new Vector2(250, 125);
        }
        public Texture2D  StartTexture
        {
            get {return f_startButtonTexture ;} 
        }
        public Texture2D ExitTexture
        {
            get { return f_exitButtonTexture ; }
        }
        public Vector2 StartPos
        {
            get { return f_startButtonPos; }
        }
        public Vector2 ExitPos
        {
            get { return f_exitButtonPos ; }
        }
        public void Draw(SpriteBatch InSpriteBatch)
        {
            InSpriteBatch.Begin();
            InSpriteBatch.Draw(f_backgroundTexture, f_backgroundPos, Color.White);
            InSpriteBatch.Draw(f_startButtonTexture, f_startButtonPos, Color.White);
            InSpriteBatch.Draw(f_exitButtonTexture, f_exitButtonPos, Color.White);
            InSpriteBatch.End();
        }
        public bool GameStart() // This one checks that the mouse is in the position where picture Starta Spel is.
        {

            if (Mouse.GetState().X > f_startButtonPos.X && Mouse.GetState().X < f_startButtonPos.X + f_startButtonTexture.Width)
            {
                if (Mouse.GetState().Y > f_startButtonPos.Y && Mouse.GetState().Y < f_startButtonPos.Y + f_startButtonTexture.Height)
                {
                    if (Mouse.GetState().LeftButton == ButtonState.Pressed)
                    {
                        return true; // Returns true if mouse is clicked in Starta Spel area
                    }
                    return false;
                }
                return false;
            }
            return false;
        }        // Returns false if mouse click is not clicked in Starta Spel area.
        public bool GameExit() // This one checks that the mouse is in the position where picture Starta Spel is.
        {

            if (Mouse.GetState().X > f_exitButtonPos.X && Mouse.GetState().X < f_exitButtonPos.X + f_exitButtonTexture.Width)
            {
                if (Mouse.GetState().Y > f_exitButtonPos.Y && Mouse.GetState().Y < f_exitButtonPos.Y + f_exitButtonTexture.Height)
                {
                    if (Mouse.GetState().LeftButton == ButtonState.Pressed)
                    {
                        return true; // Returns true if mouse is clicked in Starta Spel area
                    }
                    return false;
                }
                return false;
            }
            return false;
        }        // Returns false if mouse click is not clicked in Starta Spel area.
    }
}
